using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Ink;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFPhysics1
{
	/// <summary>
	/// Interaction logic for Editor.xaml
	/// </summary>

	public partial class Editor : System.Windows.Controls.Page
	{
		public Editor()
		{
			InitializeComponent();

			StrokeAdapter strokes = Strokes;
			if ( strokes != null && strokes.Strokes != null ) inkCanvas.Strokes.Add( strokes.Strokes );
		}

		public void inkCanvas_StrokeCollected( object sender, InkCanvasStrokeCollectedEventArgs e )
		{
		}

		public void runButton_Click( object sender, RoutedEventArgs e )
		{
			Save();
			NavigationService.Navigate( new Uri( "Player.xaml", UriKind.RelativeOrAbsolute ) );
		}

		private void Save()
		{
			StrokeAdapter strokes = Strokes;

			if ( strokes != null )
			{
				strokes.Initialize( inkCanvas.Strokes, ActualWidth, ActualHeight );
			}
		}

		protected StrokeAdapter Strokes
		{
			get { return (StrokeAdapter)( Application.Current.Resources[ "strokes" ] as ObjectDataProvider ).Data; }
		}
	}
}